package com.example.daily.di

import android.content.Context
import com.example.daily.data.AppDatabase
import com.example.daily.data.UserPreferences
import com.example.daily.data.dao.ChatMessageDao
import com.example.daily.data.dao.FoodRecordDao
import com.example.daily.data.dao.UserDao
import com.example.daily.data.dao.WeightRecordDao
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object DatabaseModule {
    
    @Provides
    @Singleton
    fun provideDatabase(@ApplicationContext context: Context): AppDatabase {
        return AppDatabase.getInstance(context)
    }

    @Provides
    @Singleton
    fun provideUserPreferences(@ApplicationContext context: Context): UserPreferences {
        return UserPreferences(context)
    }

    @Provides
    fun provideUserDao(database: AppDatabase): UserDao {
        return database.userDao()
    }

    @Provides
    fun provideWeightRecordDao(database: AppDatabase): WeightRecordDao {
        return database.weightRecordDao()
    }

    @Provides
    fun provideFoodRecordDao(database: AppDatabase): FoodRecordDao {
        return database.foodRecordDao()
    }

    @Provides
    fun provideChatMessageDao(database: AppDatabase): ChatMessageDao {
        return database.chatMessageDao()
    }
} 